<template>
  <div>
   <p class="title">推荐歌单</p>
    <van-row gutter="6">
      <van-col span="8" v-for="v in songList" :key="v.id">
        <van-image width="100%" height="3.222rem" :src="v.picUrl"></van-image>
        <p class="song_name">{{v.name}}</p>
      </van-col>
    </van-row>
    <p class="title">最新音乐</p>
    <van-cell-group>
      <!-- <van-cell center v-for="v in newList" :key="v.id" :title="v.name" :label="v.song.artists[0].name+' - '+v.song.album.name" >
        <template #right-icon>
          <van-icon name="play-circle-o"  size="0.8rem"/>
        </template>
      </van-cell> -->

      <SongItem v-for="v in newList" :key="v.id" :title="v.name" :label="v.song.artists[0].name+' - '+v.song.album.name"></SongItem>

    </van-cell-group>
  </div>
</template>

<script>
import { recommendSongListAPI, recommendNewListAPI } from '@/api/index.js'
import SongItem from '@/components/SongItem.vue'
export default {
  components: {
    SongItem
  },
  data(){
    return {
      songList: [], // 推荐歌单数据
      newList: [],
    }
  },
  async created(){
    // 获取推荐歌单
    let res
    res = await recommendSongListAPI({limit: 6});
    this.songList = res.data.result
    console.log(res);
    // 获取最新歌单
    res = await recommendNewListAPI({limit: 10});
    this.newList = res.data.result
    console.log(res);
  }
}
</script>

<style scoped>
/* 标题 */
.title {
  padding: 0.266667rem 0.24rem;
  margin: 0 0 0.24rem 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 0.346667rem;
  padding: 0 0.08rem;
  margin-bottom: 0.266667rem;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
</style>